using System;
using System.Collections.Generic;

namespace AtletIS.DomainModel.Entities.Main
{
    public partial class Competition : EntityBase
    {
        public Competition()
        {
            this.DisciplineLists = new List<DisciplineList>();
            this.ChipData = new List<ChipData>();
        }

        public int ID { get; set; }
        public string Name { get; set; }
        public string City { get; set; }
        public string Organiser { get; set; }
        public Nullable<System.DateTime> DateFrom { get; set; }
        public Nullable<System.DateTime> DateTo { get; set; }
        public Nullable<System.DateTime> Deadline { get; set; }
        public bool ClubsCountries { get; set; }
        public Nullable<int> Lanes { get; set; }
        public string LanesQuality { get; set; }
        public int? Code { get; set; }
        public int? MeasurementId { get; set; }
        public bool Active { get; set; }
        public bool Sync { get; set; }
        public int? WebId { get; set; }
        public Nullable<System.DateTime> Modified { get; set; }
        
        public bool Public { get; set; }
        public bool External { get; set; }
        public string Website { get; set; }
        public string PreAttachments { get; set; }
        public string PostAttachments { get; set; }

        public ICollection<DisciplineList> DisciplineLists { get; set; }
        public ICollection<ChipData> ChipData { get; set; }

        public string CompetitionInfo
        {
            get
            {
                string s = string.Format("{0} {1}", this.City, this.DateFrom.Value.ToString("dd.MM.yyyy"));

                if (this.DateTo.HasValue && this.DateTo.Value != this.DateFrom.Value)
                {
                    s += " - " + this.DateTo.Value.ToString("dd.MM.yyyy");
                }
                return s;
            }
        }

        public string[] aLanesQuality 
        {
            get
            {
                return this.LanesQuality.Split(',');
            }
        }
    }
}
